package com.jt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jt.mapper.RightsMapper;
import com.jt.pojo.Rights;
import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RightsServiceImpl implements RightsService{
    @Autowired
    private RightsMapper rightsMapper;

    //菜单的一级菜单套二级菜单
    @Override
    public List<Rights> getRightsList() {
        QueryWrapper<Rights> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parent_id", 0);
        List<Rights> oneList = rightsMapper.selectList(queryWrapper);
        for (Rights rightsList:oneList) {
            queryWrapper.clear();
            queryWrapper.eq("parent_id", rightsList.getId());
            List<Rights> twoList = rightsMapper.selectList(queryWrapper);
            rightsList.setChildren(twoList);
        }
        return oneList;
    }

}
